CREATE TABLE [dbo].[TDREPO_FINA]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[TI_REPO] [dbo].[TD_VC_001] NOT NULL,
[TI_REPO_EMPR] [dbo].[TD_VC_001] NOT NULL,
[CO_REPO] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TDREPO_FI__NU_AN__0E6E26BF] DEFAULT (datepart(year,getdate())),
[NU_SECU] [dbo].[TD_IN_001] NOT NULL,
[NU_FILA] [dbo].[TD_IN_001] NOT NULL,
[ST_OCUL] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TDREPO_FI__ST_OC__10566F31] DEFAULT ('N'),
[CO_FORM] [dbo].[TD_VC_008] NULL,
[PA_0001] [dbo].[TD_VC_004] NULL,
[PA_0002] [dbo].[TD_VC_004] NULL,
[PA_0003] [dbo].[TD_VC_004] NULL,
[PA_0004] [dbo].[TD_VC_010] NULL,
[PA_0005] [dbo].[TD_VC_001] NULL,
[PA_0006] [dbo].[TD_VC_003] NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NULL,
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[CO_ORDE_SERV] [dbo].[TD_VC_020] NULL,
[IM_COLU_0001] [dbo].[TD_VC_050] NULL,
[IM_COLU_0002] [dbo].[TD_VC_050] NULL,
[IM_COLU_0003] [dbo].[TD_VC_050] NULL,
[IM_COLU_0004] [dbo].[TD_VC_050] NULL,
[IM_COLU_0005] [dbo].[TD_VC_050] NULL,
[IM_COLU_0006] [dbo].[TD_VC_050] NULL,
[IM_COLU_0007] [dbo].[TD_VC_050] NULL,
[IM_COLU_0008] [dbo].[TD_VC_050] NULL,
[IM_COLU_0009] [dbo].[TD_VC_050] NULL,
[IM_COLU_0010] [dbo].[TD_VC_050] NULL,
[IM_COLU_0011] [dbo].[TD_VC_050] NULL,
[IM_COLU_0012] [dbo].[TD_VC_050] NULL,
[IM_COLU_0013] [dbo].[TD_VC_050] NULL,
[IM_COLU_0014] [dbo].[TD_VC_050] NULL,
[IM_COLU_0015] [dbo].[TD_VC_050] NULL,
[DE_GLOS] [dbo].[TD_VC_100] NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDREPO_FI__FE_US__1332DBDC] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDREPO_FI__FE_US__14270015] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [CK__TDREPO_FI__CO_CN__123EB7A3] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [CK__TDREPO_FI__NU_AN__0F624AF8] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [CK__TDREPO_FI__ST_OC__114A936A] CHECK (([ST_OCUL]='N' OR [ST_OCUL]='S'))
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [CK__TDREPO_FI__TI_RE__0C85DE4D] CHECK (([TI_REPO]='C' OR [TI_REPO]='E'))
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [CK__TDREPO_FI__TI_RE__0D7A0286] CHECK (([TI_REPO_EMPR]='C' OR [TI_REPO_EMPR]='F' OR [TI_REPO_EMPR]='P'))
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [XPKTDREPO_FINA] PRIMARY KEY CLUSTERED  ([CO_EMPR], [TI_REPO], [TI_REPO_EMPR], [CO_REPO], [NU_ANNO], [NU_SECU]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDREPO_FINA] ADD CONSTRAINT [FK1_TCREPO_FINA_A_TDREPO_FINA] FOREIGN KEY ([CO_EMPR], [TI_REPO], [TI_REPO_EMPR], [CO_REPO], [NU_ANNO]) REFERENCES [dbo].[TCREPO_FINA] ([CO_EMPR], [TI_REPO], [TI_REPO_EMPR], [CO_REPO], [NU_ANNO])
GO
